<?php

use yii\helpers\Html;
use metronic\grid\GridView;
?>

<?= GridView::widget([
    'dataProvider' => $dataProvider,
    'columns' => [
        ['class' => 'yii\grid\SerialColumn'],
        
        [
            'label' => '封面',
            'format' => 'raw',
            'value' => function($model) {
                return Html::img($model->book->cover->resize(100, 75));;
            }
        ],

        [
            'attribute' => 'book.name',
            'format' => 'raw',
            'value' => function ($model) {
                return Html::a($model->book->name, ['/book/view', 'id' => $model->book->id]);

            }
        ],
        'book.author',
        'display_order',

        [
            'class' => 'metronic\grid\ActionColumn',
            'template' => '{update} {delete} {up}',
            'buttons' => [
                'update' => function ($url, $model) {
                    return Html::updateActionButton(['update', 'recommend_id' => $model->recommend_id, 'id' => $model->id]);
                },
                'delete' => function ($url, $model) {
                    return Html::deleteActionButton(['delete', 'recommend_id' => $model->recommend_id, 'id' => $model->id]);
                },
                'up' => function($url, $model) {
                    return Html::a('<i class="fa fa-arrow-up">置顶</i>', ['/recommend-book/up', 'id' => $model->id], ['class' => 'btn btn-outline btn-circle btn-xs blue']);
                }
            ],
        ],
    ],
]); ?>
